package org.yi.fc.controller.admin.column;

import org.yi.fc.controller.base.BaseController;
import org.yi.fc.entity.FColumn;
import org.yi.fc.entity.FSysUser;

import com.jfinal.log.Log4jLogger;
import com.jfinal.log.Logger;

public class ColumnController extends BaseController {
	
	public final static Logger logger = Log4jLogger.getLogger(ColumnController.class);
	
	public void list(){
		//render("contentList.html");
	}
	
	/**
	 * 添加栏目 
	 */
	public void addColumn(){
		render("addColumn.html");
	}
	
	public void index(){
		render("column.html");
	}
	
	public void saveColumn(){
		
		if(isPostMethod()){
			try{
				FColumn fColumn = getModel(FColumn.class);
				fColumn.saveColumn(((FSysUser)getSessionAttr("f_sys_user")).getStr("username"));
				addMessage("栏目保存成功");
				setAttr("msgStatus", SUCCESS);
			}catch(Exception e){
				logger.error("保存栏目失败",e);
				addMessage("保存栏目失败:\n" + e.getMessage());
				setAttr("msgStatus", ERROR);
			}finally{
				index();
			}
		}else{
			String msg = "不能使用GET方法提交栏目数据进行保存";
			addMessage(msg);
			setAttr("msgStatus", ERROR);
			logger.warn(msg);
			index();
		}
	}
	
}
